// types/dashboard.ts

export interface StatisticCard {
    title: string
    value: number | string
    unit?: string
    trend?: number
    trendType?: 'up' | 'down'
    icon?: string
    color?: string
}

export interface ChartData {
    name: string
    value: number
    percentage?: number
    subValue?: string
}

export interface DonutChart {
    title: string
    value: number
    subValue: string
    categories?: {
        name: string
        value: string
        color: string
    }[]
}

export interface RankingItem {
    rank?: number
    company: string
    branch: string
    rate: number
    trend?: 'up' | 'down' | 'stable'
}

export interface CallRecord {
    task: string
    callCount: string | number
    connectRate: string | number
    resetCount: string | number
    hasMore?: boolean
}

export interface TransferRecord {
    time: string
    customer: string
    product: string
    transactionDate: string
    premium: string | number
    status?: 'success' | 'pending' | 'failed'
    hasMore?: boolean
}

export interface DashboardState {
    loading: boolean
    statistics: {
        maintenanceRate: {
            current: number
            target: number
            achieved: number
            percentage: number
        }
        achievementRate: {
            monthly: number
            cumulative: number
            yearEnd: number
        }
        aiCalls: {
            totalCalls: number
            connectedCalls: number
            connectionRate: number
        }
        transfers: {
            successful: number
            pending: number
            total: number
        }
    }
    charts: {
        lineChart: {
            xAxis: string[]
            data: number[]
        }
        donutCharts: DonutChart[]
    }
    rankings: RankingItem[]
    callRecords: CallRecord[]
    transferRecords: TransferRecord[]
}

export interface FilterOptions {
    year: string
    month: string
    dataType: 'premium' | 'count'
    timeRange?: [Date, Date]
    department?: string
}

// API Response types
export interface ApiResponse<T> {
    code: number
    message: string
    data: T
    timestamp: number
}

export interface DashboardApiData {
    statistics: DashboardState['statistics']
    charts: DashboardState['charts']
    rankings: DashboardState['rankings']
    recentActivities: {
        calls: CallRecord[]
        transfers: TransferRecord[]
    }
}
